ordered_types <- pokemon %>%
mutate(`Type 1` = reorder(`Type 1`, Total, FUN = median)) %>%
pull(`Type 1`) %>%
levels()
p1 <- ggplot(shared_pokemon, aes(x = `Type 1`, y = Total, fill = `Type 1`)) +
geom_boxplot() +
scale_x_discrete(limits = ordered_types) +
labs(x = "Pokemon Type")
ggplotly(p1)